package com.lyf.alg.review842.salary2012;

import java.util.HashMap;

/**
 * @AUTHOR LYF
 * @DATE 2022/2/25
 * @VERSION 1.0
 * @DESC
 * 一、、设计一个薪酬管理系统(多人
 *
 * OOP-
 * 属性：salary,name
 * 操作：存储，取钱
 *
 *
 */
class Person{
    private String name;
    private Integer age;
    private Integer salary;

    public Person(String name, Integer age, Integer salary) {
        this.name = name;
        this.age = age;
        this.salary = salary;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Integer getSalary() {
        return salary;
    }

    public void setSalary(Integer salary) {
        this.salary = salary;
    }
}

public class SalaryManage2012 {
    // 存储该用户的salary[银行]
    private HashMap<String,Integer> storage = new HashMap<>();

    // 开户
    boolean openAccount(String name){
        storage.put(name,0);
        return true;
    }
    // 存储钱
    boolean save(Person person,Integer money) throws Exception {
        // 考虑存钱金额问题
        if(person.getSalary()<money){
            throw new Exception("金额不足");
        }
        person.setSalary(person.getSalary()-money);
        storage.put(person.getName(),(Integer) storage.get(person.getName())+money);
        return true;
    }

    boolean getMoney(){
        return true;
    }
}
